package com.springcloud.redisclient.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.springcloud.redisclient.util.JedisUtil;

@RestController
@RequestMapping(value = "/redis")
public class RedisController {

	@Autowired
	JedisUtil jedisutil;

	@PostMapping(value="/setString")
	public void setString(@RequestParam String key,@RequestParam String value,@RequestParam(defaultValue="1000000") int timeout){
		jedisutil.set(key, value, timeout);
	}

	@GetMapping(value ="/getString/{key}")
	public String getString(@PathVariable("key") String key){
		return jedisutil.get(key);
	}
	
}
